package com.kingtone.rongji;

import android.app.Activity;
import android.content.Context;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.kingtone.rongji.biz.CommonMessage;
import com.kingtone.rongji.network.IRequestHandler;
import com.kingtone.rongji.ui.ToastManager;

public class BaseActivity extends Activity implements IRequestHandler{

	protected Activity mContext;
	
	@Override
	protected void onCreate(Bundle paramBundle) {
		super.onCreate(paramBundle);
		this.mContext = this;
		RongJiApplication.getInstance().addActivity(this);
	}
	
	@Override
	public void onNetworkFailure() {
		// TODO Auto-generated method stub
		ToastManager.show(mContext, mContext.getResources().getString(R.string.networkError));
	}
	
	@Override
	public void onBussinessError(String errorMessage) {
		// TODO Auto-generated method stub
		ToastManager.show(mContext, errorMessage);
	}

	@Override
	public void onBussinessSuccess() {
	}

	@Override
	public void onBussinessSuccess(Object obj) {
		// TODO Auto-generated method stub
		
	}

	@Override
	public Context getContext() {
		// TODO Auto-generated method stub
		return mContext;
	}
	
	protected void initTitleView(String titleStr) {
		TextView title = (TextView) this.findViewById(R.id.title);
		title.setText(titleStr);
		ImageView backBtn = (ImageView)this.findViewById(R.id.back);
		backBtn.setOnClickListener(new View.OnClickListener() {
			@Override
			public void onClick(View v) 
			{
				mContext.onBackPressed();
			}
		});
	}

	@Override
	public void onBussinessSuccessWithToast(CommonMessage common) {
		// TODO Auto-generated method stub
		
	}
}
